﻿Partial Class Paginas_InscribirConvenio
    Inherits System.Web.UI.Page
#Region "Funciones de la Página"
    Public Function OpcionesConvenio(ByVal Activo As String, ByVal Codigo As String) As String
        Dim strHTML As String = ""
        strHTML = "<img src='img/publicar.gif' style='cursor:pointer;' alt='Inscribir Convenio' onClick='ReenviarPag(1," & Codigo.Trim & ");'/>&nbsp;&nbsp;"
        Return strHTML
    End Function

    Private Sub CargarConvenios()
        Dim miCollect As New Collection
        Dim miNegConv As New dllNegocio.NegConvenios(System.Configuration.ConfigurationManager.AppSettings.Get("SPECBDD"))
        Try
            Session("SeekConvenio") = Me.txtNombreConvenio.Text.Trim
            miCollect = miNegConv.ListarConveniosPublicados(0, IIf(Me.txtNombreConvenio.Text.Trim = "", "TODOS", Me.txtNombreConvenio.Text.Trim), Me.ddlTipoAsistencia.SelectedItem.Value.Trim)
            Me.GrillaResultados.DataSource = miCollect
            Me.GrillaResultados.DataBind()
        Catch ex As Exception
        Finally
            miCollect = Nothing
            miNegConv.Dispose()
            miNegConv = Nothing
        End Try
    End Sub

    Private Sub CargarCombos()
        Dim miCollect As New Collection
        Dim miNegTAdm As New dllNegocio.NegTiposAsistente(System.Configuration.ConfigurationManager.AppSettings.Get("SPECBDD"))
        Try
            miCollect = miNegTAdm.ListaTipoAsistenteVigente()
            Me.ddlTipoAsistencia.DataSource = miCollect
            Me.ddlTipoAsistencia.DataTextField = "Descripcion"
            Me.ddlTipoAsistencia.DataValueField = "Codigo"
            Me.ddlTipoAsistencia.DataBind()
            Me.ddlTipoAsistencia.Items.Insert(0, New ListItem("--Selecione Tipo de Asistente--", "0"))
        Catch ex As Exception
        Finally
            miCollect = Nothing
            miNegTAdm.Dispose()
            miNegTAdm = Nothing
        End Try
    End Sub
#End Region

    Protected Sub btnBuscar_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnBuscar.Click
        Call CargarConvenios()
    End Sub

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not Page.IsPostBack Then
            Call CargarCombos()
            If Request.QueryString("PostBack") = "SI" Then
                Me.txtNombreConvenio.Text = Session("SeekConvenio")
                Call CargarConvenios()
            End If
        End If
    End Sub

End Class
